package com.boot.dog.web.aop;

import com.boot.dog.entities.pojo.Log;
import com.boot.dog.service.LogService;
import lombok.AllArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @Author: MaxLv
 * @Date: 2020/1/19
 */
@Component
@AllArgsConstructor
public class SysLogListener {

    private final LogService logService;

    @Async
    @Order
    @EventListener(SysLogEvent.class)
    public void saveSysLog(SysLogEvent event) {
        Log log = (Log) event.getSource();
        logService.save(log);
    }
}
